package libra;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("test")
public class TestController {
	
	@RequestMapping("req")
	public String req( String para, HttpServletRequest req ){
		req.setAttribute("para", para);
		req.setAttribute("list", new ArrayList<Object>() {{
			add("list_1");
			add("list_2");
			add("list_3");
			add("list_4");
			add("list_5");
		}});
		req.setAttribute("map", new HashMap<String, String>(){{
			put("key_1", "val_1");
			put("key_2", "val_2");
			put("key_3", "val_3");
			put("key_4", "val_4");
		}});
		return "req";
	}
	@RequestMapping("reqAjax")
	@ResponseBody
	public Object reqAjax( HttpServletRequest req ){
		return List.of( Map.of("K1","V1","K2","V2","K3","V3") );
	}
	
}
